<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>语料查询</title>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <!-- 引入 jquery CDN -->
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>

    <style>
        /* 全局样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Poppins', sans-serif;
        }

        body {
            background: linear-gradient(135deg, #e0f7fa, #f4f4f9);
            min-height: 100vh;
        }

        /* 导航栏优化 */
        .navbar {
            height: 80px;
            background: linear-gradient(45deg, #0084ff, #00c3ff);
            display: flex;
            align-items: center;
            padding: 0 60px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            position: fixed;
            width: 100%;
            z-index: 100;
            gap: 30px;
        }

        .navbar a {
            color: #fff;
            font-size: 1rem;
            font-weight: 500;
            text-decoration: none;
            padding: 12px 20px;
            border-radius: 20px;
            transition: background-color 0.3s ease;
        }

        .navbar a:hover {
            background-color: rgba(255, 255, 255, 0.1);
        }

        .navbar a.active {
            background: rgba(255, 255, 255, 0.15);
        }

        .main-container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 120px 40px 40px;
        }

        /* 语料查询模块新增样式 */
        .corpus-query {
            background: #fff;
            padding: 30px 40px;
            border-radius: 16px;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
        }

        .corpus-query h1 {
            font-size: 2.2rem;
            font-weight: 600;
            color: #1a1a1a;
            margin-bottom: 30px;
        }

        .search-group {
            display: flex;
            align-items: center;
            gap: 20px;
            margin-bottom: 30px;
        }

        .search-group input {
            flex: 1;
            padding: 14px 24px;
            border: 1px solid #e0e0e0;
            border-radius: 24px;
            font-size: 1rem;
            color: #333;
        }

        .search-group button {
            padding: 14px 32px;
            background: linear-gradient(45deg, #0084ff, #00c3ff);
            color: #fff;
            border: none;
            border-radius: 24px;
            cursor: pointer;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
            transition: transform 0.3s ease;
        }

        .search-group button:hover {
            transform: translateY(-2px);
        }

        .result-item {
            background: #f9f9f9;
            padding: 20px 24px;
            border-radius: 12px;
            margin-bottom: 15px;
            line-height: 1.6;
        }

        .result-item strong {
            color: #0084ff;
            font-weight: 500;
        }

        @media (max-width: 768px) {
            .search-group {
                flex-direction: column;
                gap: 15px;
            }

            .search-group input {
                width: 100%;
            }
        }
    </style>
</head>

<body>
    <div class="navbar">
        <a href="/MainPagehtml/MainPage.html">首页</a>
        <a href="/analysis">情感分析</a>
        <a href="/MainPagehtml/CorpusImport.html">语料导入</a>
        <a href="/MainPagehtml/CorpusModify.html">语料修改</a>
        <a href="/MainPagehtml/CorpusQuery.html" class="active">语料查询</a> <!-- 激活状态 -->
        <a href="/MainPagehtml/userModelCorpus.html">模型语料</a>
        <!--<a href="/MainPagehtml/ModelShow.html">模型效果</a>-->
    </div>

    <div class="main-container">
        <div class="corpus-query">
            <h1>查询语料库</h1>
            <div class="search-group">
                <input type="text" id="queryInput" placeholder="输入情感标识（如：正面、负面、中性）">
                <button onclick="searchCorpus()">开始查询</button>
            </div>

            <div id="resultArea">
                <!-- 示例结果，实际通过JavaScript动态生成 -->
                <div class="result-item">
                    <strong>匹配结果 #</strong><br>
                    语料内容："等待语料查询并展示..."
                </div>
            </div>
        </div>
    </div>

    <script>
        //搜索用户插入的新语料
        function searchCorpus() {
            const label = document.getElementById('queryInput').value.trim().toLowerCase();
            const resultArea = document.getElementById('resultArea');

            if (!label) {
                resultArea.innerHTML = '<p class="result-item">请输入查询的情感关键词</p>';
                return;
            }

            $.ajax({
                method: 'Post',
                url: '/query',
                dataType: 'json',
                contentType: 'application/json;charset=utf-8',
                data: JSON.stringify({
                    'label': label
                }),
                success: function (data) {
                    var content = data.status;
                    if (content === 'fail') {
                        resultArea.innerHTML = '<p class="result-item"><strong>匹配结果 # </strong><br>未找到匹配的语料</p>';
                    } else {
                        resultArea.innerHTML = `<div class="result-item"> <strong>匹配结果 # </strong><br>${content}</div>`;
                    }
                }
            });
        }

        //1.用户搜索系统内训练模型的原始语料
        //2.搜索方式不按情感标签，按内容匹配搜索
        /*...*/
        //8.拿到相应的语料数据，反馈到页面

        // 导航栏激活状态
        const currentUrl = window.location.href;
        const navLinks = document.querySelectorAll('.navbar a');
        navLinks.forEach(link => {
            if (currentUrl.includes(link.getAttribute('href'))) {
                link.classList.add('active');
            }
        });
    </script>
</body>

</html>    
